- /* scfcosbs.cpp by K.Tsuru */
- // function ID = 9121 since ver.2.18
- /*****************************************
- SComplex class
- It returns cos(z) using binary splitting method.
- Let z = x+iy,
- cos(z) = cos(x)*cosh(y)-i*sin(x)sinh(y).
- *****************************************/
- #ifndef SN_H
- #include "sn.h"
- #endif
- SComplex CcosBS(const SComplex& z){
- SDouble c, s, ch, sh;
- CosSinBS(z.Real(), c, s); // c = cos(x), s = sin(x)
- SDouble e, r;
- int is = z.Imag().Sign(9121);
-
- if(is > 0) {
- e = ExpBS(z.Imag()); // = exp(y)
- r = 1/e;
- ch = DDiv2(e + r); // = cosh(y)
- sh = ch - e; // = -sinh(y)
- } else if(is == 0) {
- ch = 1.0; sh = 0.0;
- } else {
- e = ExpBS(-z.Imag()); // = exp(-y)
- r = ONE/e;
- ch = DDiv2(e + r); // = cosh(-y)
- sh = ch - r; // = -sinh(-y)
- }
- return SComplex(c * ch, s * sh);
- }
scfcosbs.cpp : last modifiled at 2017/08/22 20:49:19(836 bytes)
created at 2017/10/06 15:21:28
The creation time of this html file is 2017/10/06 15:27:09 (Fri Oct 06 15:27:09 2017).